#pragma once

#include <iostream>
#include <functional>
#include <vector>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>

using task_t = std::function<void()>;

void DownLode()
{
    std::cout << "我是一个下载任务" << std::endl;
}

void PrintLog()
{
    std::cout << "我是一个打印日志任务" << std::endl;
}

void PlayVideo()
{
    std::cout << "我是一个播放视频的任务" << std::endl;
}

class Init
{
public:
    int g_downlode = 0;
    int g_printlog = 1;
    int playvideo = 2;
    std::vector<task_t> tasks;
public:
    Init()
    {
        tasks.push_back(DownLode);
        tasks.push_back(PrintLog);
        tasks.push_back(PlayVideo);
    }

    bool Check(int code)
    {
        if (code >= 0 && code < tasks.size())
            return true;
        else
            return false;
    }

    void Run(int code)
    {
        tasks[code]();
    }

    int SelectTask()
    {
        return rand() % tasks.size();
    }
};

Init init;